Formulae

Understanding and using formulae

How to Use Formulae

Formulae are configured in the Define Formula dialog. The arguments vary with each application; these can be elements, data fields or other. However, the following rules apply regardless:

  • Formulae start with “=”.

  • Formulae can include numbers, arithmetic and logical operators, and built-in functions.

  • Formulae syntax is checked automatically after you click OK in the dialog.

Operator

Precedence

Definition

**

13

Exponentiation

+

12

Unary plus

-

12

Unary minus

!

12

Logical not

*

11

Multiplication

/

11

Division

%

11

Remainder (integer)

+

10

Addition

-

10

Subtraction

< 

8

Less than

> 

8

Greater than

<=

8

Less than or equal

>=

8

Greater than or equal

==

7

Equal

!=

7

Not equal

&&

3

Logical And

||

2

Logical Or

 

In formulae with more than one operator, the program evaluates operators in the order of precedence presented above, with the highest precedence being processed first. That is, AND/OR/NOT operators are evaluated after inequality operators in a logical expression, and multiplication/division operations are performed before subtraction/addition operations in an arithmetic expression.

Operators at the same precedence level are evaluated from left to right. The precedence of operators can be overridden by using parentheses to explicitly specify the order of evaluation.

note.gif (1017 bytes)

In some cases, formulae may not function properly if the decimal symbol is set to comma (,) rather than period (.) in the Windows Regional.

 

Built in functions

The letters X and Y below denote generic arguments. In the actual formulae, they would be replaced by symbols of the elements.

abs(X)

The absolute value of X

acos(X)

The arc cosine of X

asin(X)

The arc sine of X

atan(X)

The 2-quadrant arc tangent of X

atan2(X, Y)

The 4-quadrant arc tangent of Y/X

ceil(X)

The smallest integer greater than or equal to X

cos(X)

The cosine of X

cosh(X)

The hyperbolic cosine of X

exp(X)

e raised to the power X

floor(X)

The largest integer less than or equal to X

frac(X)

The fractional portion of X

int(X)

The integer portion of X

ln(X)

The natural log of X

log(X) or log10(X)

The log base 10 of X

log2(X)

The log base 2 of X

pi

The value of pi

sin(X)

The sine of X

sinh(X)

The hyperbolic sine of X

sqrt(X)

The positive square root of X

tan(X)

The tangent of X

tanh(X)

The hyperbolic tangent of X

if(X, T, F)

The value of T if X is true (evaluates) to nonzero, or F if X is false (evaluates to zero).

and(...)

if any arguments are 0; 1 if all arguments are 1; otherwise -1

nand(...)

0 if all arguments are 1; 1 if any arguments are 0; otherwise -1.

not(X)

0 if X is 1; 1 if X is 0; otherwise -1

or(...)

0 if all arguments are 0, 1 if any arguments are 1; otherwise -1.

xor(...)

-1 if any of the arguments are not 0 or 1; otherwise 0 if the total number of arguments with the value 1 is even; 1 if the total number of arguments with the value 1 is odd.

 

Example 1 (recovery)

Suppose you want to define the recovery fraction (F) as a step function of the grade (AU) as follows:

  • F=0.0 for 0.0<=AU<1.0

  • F=0.4 for 1.0<=AU<1.5

  • F=0.6 for 1.5<=AU<2.0

  • F=0.9 for AU>=2.0.

The formula defining such a function is:

=if(AU>=1.0&&AU<1.5,0.4,0.0)+if(AU>=1.5&&AU<2.0,0.6,0.0)+if(AU>=2.0,0.9,0.0)

Example 2 (recovery)

Suppose you want to define the recovery to be 0 for AU less than 1, change from 0 to 0.95, proportionally to AU, in the interval 1 to 2, and stay constant at 0.95 for AU greater than 2. The formula defining such a function can look as follows:

=if(AU>=1.0&&AU<2.0,0.95*(AU-1.0),0.0)+if(AU>=2.0,0.95,0.0)

or:

=0.95*min(1,max(0.0,AU-1.0))

Example 3 (processing cost)

The processing costs are proportional to ore input at $3.63 per tonne and to CU input at $265.25 per tonne. CU grade is given as percentage grade, so the cost per percentage point is $2.6525. The corresponding formula is:

=3.63+2.6525*CU